namespace ghost
{
    /** 所有界面基类*/
    export class GameUIBase extends GYSprite{
        public maskBack:GYSprite;
        protected _module:Module;
        public maskClkEnabled:boolean;
        constructor(){
            super();
            let s = this;
            s.verticalCenter = 0;
            s.horizonalCenter = 0;
            s.maskBack = new GYSprite;
            s.maskBack.alpha = 0.5;
            s.maskBack.mouseThrough = false;
            s.maskBack.mouseEnabled = true;
            s.addChild(s.maskBack);
            s._module = Module.getInstance();
            s.maskBack.on(Laya.Event.CLICK, s, s.clkMask);
            s.maskClkEnabled = true;
        }
        protected clkMask(e:Laya.Event):void
        {
            let s = this;
            if(s.maskClkEnabled)
                s.hide();
        }
        public resize():void
        {
            let s = this;            
            s.maskBack.graphics.clear();
            s.maskBack.width = s._module.frameBound.width;
            s.maskBack.height = s._module.frameBound.height;
            s.maskBack.graphics.drawRect(s._module.frameBound.x,s._module.frameBound.y,s.maskBack.width,s.maskBack.height, "#000000");            
            
        }
        public show(pr:Laya.Sprite=null, mask:boolean=true, tween:boolean=true):void
        {
            if(pr == null)
                pr = Module.getInstance();
            pr.addChild(this);
            
            let s= this;
            s.maskBack.visible = mask;
            if(tween)
            {
                let toY:number;
                toY = s.y;
                s.y = toY - 50
                s.alpha = 0;
                Laya.Tween.to(s, {y:toY,alpha:1},1000,Laya.Ease.elasticOut);            
            }            
            s.resize();
            s.layout();
        }
        public hide():void
        {
            let s= this;
            if(s.parent)
            {
                s.parent.removeChild(s);
            }
        }
    }
}